package com.guan.ordering_sys.generator.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.guan.ordering_sys.common.PageResult;
import com.guan.ordering_sys.common.ResultApi;
import com.guan.ordering_sys.common.StateCode;

import com.guan.ordering_sys.generator.service.impl.PaymentProcessServiceImpl;
import com.guan.ordering_sys.vo.PaymentProcessVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 关远键
 * @since 2021-06-23
 */
@Api(tags = "支付流程接口")
@RestController
@RequestMapping("/generator/payment-process")
public class PaymentProcessController {
    @Autowired
    PaymentProcessServiceImpl paymentProcessService;

    @ApiOperation("获取支付流程")
    @GetMapping("/getPaymentProcess")
    public ResultApi getPaymentProcess(@ApiParam("当前页面") int pageNum, @ApiParam("页面大小") int pageSize) {
        Page<PaymentProcessVo> paymentProcessVoPage= new Page<>();
        paymentProcessVoPage.setSize(pageSize);
        paymentProcessVoPage.setCurrent(pageNum);
        IPage<PaymentProcessVo> paymentProcessVoIPage = paymentProcessService.getPaymentProcess(paymentProcessVoPage);
        if (paymentProcessVoIPage != null) {
            PageResult<PaymentProcessVo> businessModelVoPageResult = new PageResult<>(paymentProcessVoIPage.getRecords().size(), paymentProcessVoIPage.getRecords());
            return ResultApi.success(businessModelVoPageResult);
        } else {
            return ResultApi.errorNotData(StateCode.FAIL);
        }
    }

}

